class CountUpTimerController < ApplicationController
  def list
    timers = CountUpTimer.find(:all)
    respond_to do |format|
      format.json { render :json => timers }
    end
  end
  
  def start
    id = params[:id]
    now = params[:now]
    timer = CountUpTimer.find(id)
    updated_at = timer.start(now)
    respond_to do |format|
      format.json { render :json => updated_at }
    end
  end
  
  def stop
    id = params[:id]
    now = params[:now]
    timer = CountUpTimer.find(id)
    updated_at = timer.stop(now)
    respond_to do |format|
      format.json { render :json => updated_at }
    end
  end
  
  def reset
        id = params[:id]
    now = params[:now]
    timer = CountUpTimer.find(id)
    updated_at = timer.reset(now)
    respond_to do |format|
      format.json { render :json => updated_at }
    end
  end
  
  def toggle
    id = params[:id]
    now = params[:now]
    timer = CountUpTimer.find(id)
    updated_at = timer.toggle(now)
    respond_to do |format|
      format.json { render :json => updated_at }
    end
  end
end
